package com.significantfiles.properties.io.file;

import java.io.File;
import java.io.FilenameFilter;

public class EndsWithFileNameFilter implements FilenameFilter {

	private String extension;

	public EndsWithFileNameFilter(final String extension) {
		if (extension == null)
			throw new IllegalArgumentException( "Passed parameter {extension} is NULL.");

		this.extension = extension.trim();
		
		final boolean isEmptyExtension = (this.extension.length() < 1);
		
		if( isEmptyExtension ) {
			throw new IllegalArgumentException( "Passed string {extension} is empty.");
		}
	}

	public boolean accept(final File dir, final String name) {
		return name.endsWith( this.extension );
	}
}
